import Web3 from 'web3'
const contractAddress = '0x0000...0000'

const contractABI = []
var contract = null;
let web3 = new Web3(window.ethereum);
var accountAddress;

async function Init(callback) {

	if (typeof window.ethereum === "undefined") {
		alert("Looks like you need a Dapp browser to get started.\n Consider installing MetaMask!");
	} else {
		let currentProvider = web3.currentProvider;
		web3.setProvider(currentProvider);
		web3.eth.getAccounts(function(err, result) {
			console.log("getAccounts result = " + result + " error =" + err)
		});

		//Will Start the metamask extension
		const accounts = await ethereum.request({
			method: 'eth_requestAccounts'
		});
		console.log("eth_requestAccounts:" + accounts);
		callback(accounts[0])
	}
}

export default {
	Init,
}
